import {Injectable} from '@angular/core';
import {SearchResult} from '../content/model/search-result';
import {Observable} from 'rxjs';
import {ApiRes} from '../common/model/response';
import {HttpClient} from '@angular/common/http';
import {UrlService} from '../common/service/url.service';
import {map} from 'rxjs/operators';

@Injectable({
  providedIn: 'root'
})
export class PolicyAnalysisMatrixService {

  constructor(private http: HttpClient,
              private urlService: UrlService) {
  }

  searchArticle(condition: SearchResult): Observable<ApiRes> {
    const url = this.urlService.getWebUrl('/jz/searchWebV2');
    return this.http.post<ApiRes>(url, condition);

  }

  getTreeData(): Observable<ApiRes> {
    const url = this.urlService.getWebUrl('/policySearch/wordFreamList');
    return this.http.get<ApiRes>(url).pipe(map(res => {
      // res.result = this.transformTree(res.result);
      return res;
    }));

  }
}
